FROM harbor.39on.com/official/centos:php54-deploy

WORKDIR /www

COPY ./source ./source
COPY ./include ./include

RUN ln -s /usr/local/webserver/mysql/include/* /usr/local/include

# 编译扩展
WORKDIR /www/source
RUN /usr/local/webserver/php/bin/phpize
RUN ./configure --with-php-config=/usr/local/webserver/php/bin/php-config
RUN make
RUN make install 

# 复制测试脚本
WORKDIR /www

COPY ./all.php ./all.php
COPY ./helloworld.php ./helloworld.php
COPY ./curl.php ./curl.php
COPY ./mysqli_query.php ./mysqli_query.php
COPY ./mysqli_stmt.php ./mysqli_stmt.php
COPY ./pdo_insert.php ./pdo_insert.php
COPY ./pdo_query.php ./pdo_query.php
COPY ./pdo_stmt.php ./pdo_stmt.php
COPY ./phpredis.php ./phpredis.php
COPY ./predis.php ./predis.php
COPY ./composer.json ./composer.json
COPY ./composer.lock ./composer.lock
COPY ./vendor ./vendor

# 配置扩展
WORKDIR /www

COPY ./monitorpro.ini ./monitorpro.ini
RUN cat ./monitorpro.ini >> /usr/local/webserver/php/etc/php.ini \
    && sed -i 's/pm.max_children = 256/pm.max_children = 1/g' /usr/local/webserver/php/etc/php-fpm.conf

# 启动容器
WORKDIR /www

COPY ./run.sh ./run.sh
RUN touch /tmp/monitorpro.log \
    && chmod +x ./run.sh \
    && chown www.www /tmp/monitorpro.log \
    && chmod 777 /tmp/monitorpro.log
ENTRYPOINT ["./run.sh"]